package org.ourgrid.discoveryservice.business.requester;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.common.interfaces.DiscoveryService;
import org.ourgrid.common.internal.IResponseTO;
import org.ourgrid.common.internal.RequesterIF;
import org.ourgrid.common.internal.response.RegisterInterestResponseTO;
import org.ourgrid.discoveryservice.DiscoveryServiceConstants;
import org.ourgrid.discoveryservice.request.HereAreDiscoveryServicesRequestTO;

public class HereAreDiscoveryServicesRequester implements RequesterIF<HereAreDiscoveryServicesRequestTO>{
	
	

	public List<IResponseTO> execute(HereAreDiscoveryServicesRequestTO request) {
		List<IResponseTO> responses = new ArrayList<IResponseTO>();
		
		for (String address : request.getDiscoveryServicesAddresses()) {
			RegisterInterestResponseTO to = new RegisterInterestResponseTO();
			to.setMonitorableAddress(address);
			to.setMonitorableType(DiscoveryService.class);
			to.setMonitorName(DiscoveryServiceConstants.DS_MONITOR);
			
			responses.add(to);
		}
		
		return responses;
	}
	
}
